﻿using Dicide.ViewModels;
using System;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;

namespace Dicide.Components
{
    public sealed partial class Clock : UserControl
    {
        public Clock()
        {
            this.InitializeComponent();
            DataContext = _clockViewModel;
            _dispatcherTimer = new DispatcherTimer();
            _dispatcherTimer.Interval = TimeSpan.FromSeconds(1);
            _dispatcherTimer.Start();
            _dispatcherTimer.Tick += _dispatcherTimer_Tick;
        }

        void _dispatcherTimer_Tick(object sender, object e)
        {
            _clockViewModel.On = !_clockViewModel.On;
        }

        DispatcherTimer _dispatcherTimer;
        ClockViewModel _clockViewModel = new ClockViewModel();
    }
}
